﻿<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="text" />
	<xsl:template match="/">&lt;?xml version="1.0" encoding="utf-8" ?&gt;		
&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="<xsl:value-of select="Schema/@DataEntityNameSpace" />" namespace="<xsl:value-of select="Schema/@DataEntityNameSpace" />"&gt;		
	&lt;class name="<xsl:value-of select="Schema/@TableName" />" table="<xsl:value-of select="Schema/@TableName" />" lazy="true" &gt;
<xsl:for-each select="Schema/Columns[IsPK='1']">
		&lt;id name="<xsl:value-of select="ColumnName"/>" column="<xsl:value-of select="ColumnName"/>" type="<xsl:value-of select="HbmType"/>" <xsl:if test="MaxLength!=''"> length="<xsl:value-of select="MaxLength"/>" </xsl:if>&gt;
		&lt;generator class="<xsl:choose><xsl:when test="IsIdentity=1">identity</xsl:when><xsl:when test="IsRowGUIDCol=1">guid</xsl:when><xsl:otherwise>assigned</xsl:otherwise></xsl:choose>" /&gt;
		&lt;/id&gt;
</xsl:for-each>

<xsl:for-each select="Schema/Columns[IsPK='0']">
		&lt;property name="<xsl:value-of select="ColumnName"/>"  column="<xsl:value-of select="ColumnName"/>" type="<xsl:value-of select="HbmType"/>" <xsl:if test="MaxLength!=''"> length="<xsl:value-of select="MaxLength"/>" </xsl:if> <xsl:choose><xsl:when   test= "IsNullable='1' ">not-null="true"</xsl:when><xsl:otherwise>not-null="false"</xsl:otherwise></xsl:choose> /&gt;
</xsl:for-each>
	&lt;/class&gt;
&lt;/hibernate-mapping&gt;
</xsl:template>
</xsl:stylesheet>

